package controle.utilitaires;

import java.text.DateFormat; 
import java.text.ParseException; 
import java.text.SimpleDateFormat; 
import java.util.Date; 
import java.util.Locale; 


public class GestionDates {
	
	public static String dateEnChaineEN(Date laDate) { 
        Locale locale = Locale.getDefault(); 
        DateFormat dateFormat = new SimpleDateFormat 
                                         ("yyyy-MM-dd", locale); 
        String date = dateFormat.format(laDate); 
        return date; 
    } 
     
    public static String dateEnChaineFR(Date laDate) { 
        Locale locale = Locale.FRANCE; 
        DateFormat dateFormat = new SimpleDateFormat 
                                          ("dd-MM-yyyy", locale); 
        String date = dateFormat.format(laDate); 
        return date; 
    } 
 public static Date chaineENversDateJava 
                  (String laDateChaineEN) throws ParseException { 
        SimpleDateFormat dateStandard =  
                             new SimpleDateFormat ("yyyy-MM-dd"); 
        Date laDateDate= dateStandard.parse(laDateChaineEN); 
        return laDateDate; 
    } 
     
    public static String chaineDateFRversEN(String dateFR) { 
        String dateEN = ""; 
        String vAnneeEN = dateFR.substring(6, 10); 
        String vMoisEN = dateFR.substring(3,5); 
        String vJourEN = dateFR.substring(0, 2); 
        dateEN = vAnneeEN + "-" + vMoisEN + "-" + vJourEN; 
        return dateEN; 
    } 
     
    public static String chaineDateENversFR(String dateEN) { 
        String dateFR = ""; 
        String vJourFR = dateEN.substring(8, 10); 
        String vMoisFR = dateEN.substring(5,7); 
        String vAnneeFR = dateEN.substring(0,4 ); 
        dateFR = vJourFR + "/" + vMoisFR + "/" + vAnneeFR; 
        return dateFR; 
    } 
 public static Date dateJavaEnDateSQL(Date laDate) { 
        Date dateSQL = new java.sql.Date(laDate.getTime()); 
        return dateSQL; 
    } 

  
}
